-- @owner:宋菲
-- @date:2024-03-15
-- @testpoint:1.测试修改触发器，触发器名称大小写不敏感，合理报错

--开启参数
set enable_ignore_case_in_dquotes to on;

--创建表及触发器函数;expect:成功(2 rows)
create table "t_ignore_case_in_dquotes_alter_case0008"(col1 int,col2 varchar(10)); 
create or replace function "tri_func_ignore_case_in_dquotes_alter_case0008"() returns trigger as
$$
declare
begin
    insert into "t_ignore_case_in_dquotes_alter_case0008" values(new.id1, new.id2, new.id3);
    return new;
end
$$ language plpgsql;
/

--创建触发器;expect:成功(8 rows)
create trigger tri_ignore_case_in_dquotes_alter_case0008_1 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger tri_ignore_case_in_dquotes_alter_case0008_2 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger tri_ignore_case_in_dquotes_alter_case0008_3 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger "tri_ignore_case_in_dquotes_alter_case0008_!@#$%^&*()?<>:;=+-_4" 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger "tri_ignore_case_in_dquotes_alter_case0008_'''_5"
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger "tri_ignore_case_in_dquotes_alter_case0008_""""""_6" 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger "tri_ignore_case_in_dquotes_alter_case0008_''""_7" 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

create trigger tri_ignore_case_in_dquotes_alter_case0008_8 
before insert on "t_ignore_case_in_dquotes_alter_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_alter_case0008"();
/

--step1:修改触发器名为全小写;expect:成功 
alter trigger "tri_ignore_case_in_dquotes_alter_case0008_1" on t_ignore_case_in_dquotes_alter_case0008 rename to "tri_ignore_case_in_dquotes_alter_case0008_1_new";

--step2:修改触发器名为全大写;expect:成功
alter trigger "TRI_IGNORE_CASE_IN_DQUOTES_ALTER_CASE0008_2" on t_ignore_case_in_dquotes_alter_case0008 rename to "TRI_IGNORE_CASE_IN_DQUOTES_ALTER_CASE0008_2_new";

--step3:修改触发器名为大小写混合;expect:成功
alter trigger "tri_IgNOrE_CasE_IN_dquotes_alter_cASe0008_3" on t_ignore_case_in_dquotes_alter_case0008 rename to "tri_IgNOrE_CasE_IN_dquotes_alter_cASe0008_3_new";

--step4:修改触发器名带有特殊符号;expect:成功
alter trigger "tri_IGNORE_CASE_IN_dquotes_alter_CASE0008_!@#$%^&*()?<>:;=+-_4" on t_ignore_case_in_dquotes_alter_case0008 rename to "tri_IGNORE_CASE_IN_dquotes_alter_CASE0008_!@#$%^&*()?<>:;=+-_4_new";

--step5:修改触发器名带有单引号;expect:成功
alter trigger "tri_IGNORE_CASE_IN_dquotes_alter_CASE0008_'''_5" on t_ignore_case_in_dquotes_alter_case0008 rename to "tri_IGNORE_CASE_IN_dquotes_alter_CASE0008_'''_5_new";

--step6:修改触发器名带有双引号;expect:成功
alter trigger "tri_IGNORE_CASE_IN_dquotes_alter_CASE0008_""""""_6" on t_ignore_case_in_dquotes_alter_case0008 rename to "tri_IGNORE_CASE_IN_dquotes_alter_CASE0008_""""""_6_new";

--step7:修改触发器名带有单引号、双引号混合;expect:成功
alter trigger "TRI_IGNORE_CASE_IN_dquotes_alter_case0008_''""_7" on t_ignore_case_in_dquotes_alter_case0008 rename to "TRI_IGNORE_CASE_IN_dquotes_alter_case0008_''""_7_new";

--step8:异常情况，修改已经存在的小写对象名的对象;expect:报错ERROR: already exists
alter trigger "TRI_IGNORE_CASE_IN_DQUOTES_ALTER_CASE0008_8" on t_ignore_case_in_dquotes_alter_case0008 rename to TRI_IGNORE_CASE_IN_DQUOTES_ALTER_CASE0008_8;

--清理环境:expect:成功(10 rows)
drop trigger tri_ignore_case_in_dquotes_alter_case0008_1_new on t_ignore_case_in_dquotes_alter_case0008;

drop trigger tri_ignore_case_in_dquotes_alter_case0008_2_new on t_ignore_case_in_dquotes_alter_case0008;

drop trigger tri_ignore_case_in_dquotes_alter_case0008_3_new on t_ignore_case_in_dquotes_alter_case0008;

drop trigger "tri_ignore_case_in_dquotes_alter_case0008_!@#$%^&*()?<>:;=+-_4_" on t_ignore_case_in_dquotes_alter_case0008;

drop trigger "tri_ignore_case_in_dquotes_alter_case0008_'''_5_new" on t_ignore_case_in_dquotes_alter_case0008;

drop trigger "tri_ignore_case_in_dquotes_alter_case0008_""""""_6_new" on t_ignore_case_in_dquotes_alter_case0008;

drop trigger "tri_ignore_case_in_dquotes_alter_case0008_''""_7_new" on t_ignore_case_in_dquotes_alter_case0008;

drop trigger tri_ignore_case_in_dquotes_alter_case0008_8 on t_ignore_case_in_dquotes_alter_case0008;

drop table t_ignore_case_in_dquotes_alter_case0008;

drop function tri_func_ignore_case_in_dquotes_alter_case0008;

--关闭参数
set enable_ignore_case_in_dquotes to off;
